package com.moleq.adapter;

import java.util.List;

import com.moleq.adapter.EJrptSelectionAdpater.ViewHolder;
import com.moleq.models.PosEJ;
import com.moleq.models.Users;
import com.moleq.mgpos.activities.R;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class ClerkReportAdapter extends BaseAdapter {
	private LayoutInflater mInflater;
	private List<Users> Source;
	private Context context;
	private int selectedRow = 0;
	private ViewHolder holder = null;
	
	public ClerkReportAdapter(Context context, List<Users> Source) {
		this.context = context;
		this.mInflater = LayoutInflater.from(context);
		this.Source = Source;
	}

	public void setSource(List<Users> Source) {
		this.Source = Source;
	}

	public int getCount() {
		return Source.size();
	}

	public Object getItem(int position) {
		return Source.get(position);
	}

	public long getItemId(int position) {
		return position;
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		if (convertView == null) {
			holder = new ViewHolder();
			convertView = mInflater.inflate(R.layout.ej_list_item, null);
			holder.tv_cashier_name = (TextView) convertView
					.findViewById(R.id.tv_ej_name);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		holder.tv_cashier_name.setText(Source.get(position).getUs_login_id());
		if (selectedRow == position) {
			holder.tv_cashier_name.setBackgroundColor(Color.rgb(250, 183, 17));
		} else {
			holder.tv_cashier_name.setBackgroundColor(Color.rgb(247,239,181));
		}
		return convertView;
	}
	
	public final class ViewHolder {
		public TextView tv_cashier_name;
	}

	public void ScrollToRow(int row) {
		selectedRow = row;
		this.notifyDataSetChanged();
	}

	public int GetSelectedIndex() {
		return selectedRow;
	}

}
